package com.mchsdk.paysdk.http.process;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.entity.StringEntity;

import com.lidroid.xutils.http.RequestParams;
import com.mchsdk.paysdk.bean.ChannelAndGameInfo;
import com.mchsdk.paysdk.config.MCHConstant;
import com.mchsdk.paysdk.http.request.ForgmentPasswordRequest;
import com.mchsdk.paysdk.utils.MCLog;
import com.mchsdk.paysdk.utils.RequestParamUtil;

import android.os.Handler;

public class ForgmentPasswordProcess {

	private static final String TAG = "ForgmentPasswordProcess";

	/**
	 * 手机号 
	 */
	private String phone;  
	
	/**
	 * 验证码 
	 */
	private String vcode; 
	
	/**
	 * 新密码 
	 */
	private String newPassword; 
	
	private String id;
	
	private String getParamStr(){
		Map<String, String> map = new HashMap<String, String>();
//		map.put("account", PersonalCenterModel.getInstance().getAccount());
		map.put("user_id", id);
		map.put("game_id", ChannelAndGameInfo.getInstance().getGameId());
		map.put("password", newPassword);
		map.put("code", vcode);
		map.put("phone", phone);
		MCLog.e(TAG, "fun#ptb_pay params:" + map.toString());
		
		return RequestParamUtil.getRequestParamString(map);
	}
	
	public void post(Handler handler){

		RequestParams params = new RequestParams();
		try {
			params.setBodyEntity(new StringEntity(getParamStr()));
		} catch (UnsupportedEncodingException e) {
			params = null;
			MCLog.e(TAG, "fun#post UnsupportedEncodingException:" + e);
		}

		if (null != handler && null != params) {
			ForgmentPasswordRequest formentReq = new ForgmentPasswordRequest(handler);
			formentReq.post(MCHConstant.getInstance().getForgmentPasswordUrl(), params);
			return;
		} else {
			MCLog.e(TAG, "fun#post handler is null or url is null");
		}
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setVcode(String vcode) {
		this.vcode = vcode;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	
}
